//
//  ScrollViewTestVC.swift
//  CXSwiftDemo
//
//  Created by 潮汐 on 2023/12/12.
//

import UIKit

class ScrollViewTestVC: CXBaseViewController, UIScrollViewDelegate{
    //懒加载
    lazy var myScrollerView = UIScrollView()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        createUI()
    }
    
    func createUI() {
        myScrollerView.frame = CGRect(x: 0, y: MC_NavHeight, width: SCREEN_WIDTH, height: SCREEN_HEIGHT-MC_NavHeight)
        myScrollerView.backgroundColor = .orange
        myScrollerView.delegate = self
        //设置尺寸
        myScrollerView.contentSize = CGSize(width: SCREEN_WIDTH, height: SCREEN_HEIGHT * 2)
        //是否开启竖直方向回弹效果
        myScrollerView.alwaysBounceVertical = true
        //是否反弹
        myScrollerView.bounces = true
        //是否开启分页
        myScrollerView.isPagingEnabled = false
        self.view.addSubview(myScrollerView)
    }
    
    //滚动视图滚动代理--滑动过程
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        print("x:\(scrollView.contentOffset.x) y:\(scrollView.contentOffset.y)")
    }
    
    //返回将要缩放的UIView对象
    func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return UIView()
    }
    //当将要开始缩放时，执行该方法。一次有效缩放就只执行一次
    func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) {
        
    }
    //当scrollView缩放时，调用该方法。在缩放过程中，会多次调用
    func scrollViewDidZoom(_ scrollView: UIScrollView) {
        
    }
    
    //当缩放结束后，并且缩放大小回到minimumZoomScale与maximumZoomScale之间后（我们也许会超出缩放范围），调用该方法
    func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
        
    }
    //指示当用户点击状态栏后，滚动视图是否能够滚动到顶部
    func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
        //返回值：true可以返回到顶端， false不能返回到顶端
        return true
    }
    //当滚动视图滚动到最顶端后，执行该方法
    func scrollViewDidScrollToTop(_ scrollView: UIScrollView) {
        
    }
    //当开始滚动视图时，执行该方法。一次有效滑动只执行一次
    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        
    }
    //当开始滚动视图时，执行该方法。一次有效滑动只执行一次
    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
    
    }
    
    //滑动减速时调用该方法
    func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) {
        
    }
    //滚动视图减速完成，滚动将停止时，调用该方法。一次有效滑动只执行一次
    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        
    }
    //当滚动视图动画完成后，调用该方法，如果没有动画，那么该方法将不被调用
    func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
        
    }
    //滑动scrollView，并且手指离开时执行。一次有效滑动只执行一次(当pagingEnabled属性为true时，不调用该方法)
    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
        
    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
